<?php
session_cache_expire(999999999);
if(!isset($_SESSION))
{
	session_start();
}
include '../operations/connection.php';
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../value/value_en.php";
} else if($lang == "VN") {
	include "../value/value_vn.php";
}
else {
	include "../value/value_kr.php";
}

$page=$_REQUEST['page'];

$rows_per_page = 10 ;
$page_start = ( $page - 1 ) * $rows_per_page;
$page_end = $page * $rows_per_page;

$selectregular = mysql_query("Select sas.*,emp.FullName FROM sa_regulation_salary sas,employee emp
 WHERE emp.IDEmployee = sas.employeeID AND emp.State = 1 AND emp.IDEmployee != '1322887525530'");
$number_of_page = ceil ( mysql_num_rows( $selectregular ) / $rows_per_page );


?>
<form action="#" name="formCheck" method="post">
	<table class="cssTable" border="1" style="width: 100%;">
		<thead>
			<tr>
				<th scope="col" style="width: 5%; border-right: 1px solid"></th>
				<th scope="col" style="width: 13%; border-right: 1px solid"><?php echo $l_employeecode?></th>
				<th scope="col" style="width: 20%; border-right: 1px solid"><?php echo $l_employee_name?></th>
				<th scope="col" style="width: 13%; border-right: 1px solid;height: 45px; "><?php echo $l_basicsalary;?></th>
				<th scope="col" style="width: 13%; border-right: 1px solid"><?php echo $l_allowancebasicsalary;?></th>
				<th scope="col" style="width: 12%; border-right: 1px solid"><?php echo $l_allowanceC;?></th>
				<th scope="col" style="width: 12%; border-right: 1px solid"><?php echo $l_allowanceSenior;?></th>
				<th scope="col" style="width: 12%"><?php echo $l_salaryforinsurance?></th>
			</tr>
		</thead>
		<tbody>
		<?php
		if(mysql_num_rows($selectregular)>0){
			$i=0;
			while ($row = mysql_fetch_array($selectregular)){
				if ( $i >= $page_start ){
					?>

			<tr>
				<td><input type="checkbox" name="checkregularsal"
					id="<?php echo 'checkcus'.$i?>"
					onclick="processCheck(this.id,document.formCheck.checkregularsal);"
					value="<?=$row[employeeID]?>" /></td>
				<td><?php echo $row[employeeID];?></td>
				<td><?php echo $row[FullName]?></td>
				<td><?php echo number_format($row[basic_salary]);?></td>
				<td><?php echo number_format($row[allowance_basic_salary]);?></td>
				<td><?php echo number_format($row[allowance_c]);?></td>
				<td><?php echo number_format($row[allowance_senior]);?></td>
				<td><?php echo number_format($row[salary_insurance]);?></td>
			</tr>
			<?php }
			$i++;
			if ($i >= $page_end){
				break;
			}
			}
		}?>

			<tr>
				<td colspan="8" class="rf-dt-shdr-c"><span
					style="background: #eeeeee; padding: 1px; display: inline-block;width: 900px;"> <?php if ( $number_of_page > 1 ) 
					{
						if ($page==1)
						$p=2;
						else if ($page==$number_of_page)
						$p=$number_of_page-1;
						else $p=$page;
						if($page!=1){?> <a onclick="pagingregularsalary(1);"><span
							class='button_next'><?php echo "<<<";?> </span> </a> <a
						onclick="pagingregularsalary(<?=($page-1)?>);"><span
							class='button_next'><?php echo "<<";?> </span> </a> <?php  }
							else{
								echo "<span class='button_next'><<<</span> ";
								echo "<span class='button_next'><<</span> ";
							}
							for ( $i = $p-1; $i <= $p+1; $i++ ) {
								if ($i<=$number_of_page && $i>0)

								if ($i==$page){
									echo "<span class='button_next' style='color: blue;'><b>".$i."</b></span>";
								}else{
									?> <a onclick="pagingregularsalary(<?=$i?>);"><span
							class="button_next"> <?php 
							echo $i;
							?> </span> </a> <?php
								}
								?> <?php
							}

							if($page!=$number_of_page){ ?> <a
						onclick="pagingregularsalary(<?=($page+1)?>);"><span
							class='button_next'><?php echo ">>";?> </span> </a> <a
						onclick="pagingregularsalary(<?=($number_of_page)?>);"><span
							class='button_next'><?php echo ">>>";?> </span> </a> <?php }
							else{
								echo "<span class='button_next'>>></span> ";
								echo "<span class='button_next'>>>></span> ";
							}
					}


					?> </span>
				</td>
			</tr>
		</tbody>
	</table>

</form>
